<!DOCTYPE HTML>
<html>

<head>
  {include file="public/header" title="我的信息" /}
</head>

<style>
  .index_top {
    padding: 5px 0;
    text-align: center;
    background: #429ED5
  }

  .index_top h2 {
    font-size: 18px;
    color: #fff;
  }

  .my_info {
    height: 180px;
    background: #429ED5
  }

  .my_info .top {
    text-align: center;
    padding-top: 20px;
  }

  .my_info .top>img {
    height: 90px;
    width: 90px;
    display: inline-block;
    border-radius: 90px;
  }

  .my_info .top>h3 {
    color: #fff;
    font-size: 14px;
  }
</style>

<body>

  <!-- <header class="index_top">
                        <h2>我的信息</h2>
        </header> -->

  <div class="my_info">
    <div class="top">
      <img src='/static/images/boot.png'>
      <h3>{$user.nickname}</h3>
    </div>
  </div>

  <div class="weui-cells weui-cells_checkbox">
    <h3 style="padding: 8px 0; font-size: 16px; font-weight: 500; color: #a0a0a0; ">我的聊天群 (选中代表监控)</h3>
    {volist name="group_list" id="v"}
    <label class="weui-cell weui-check__label" for="s1{$i}">
      <div class="weui-cell__hd">
        <input type="checkbox" class="weui-check" name="checkbox" id="s1{$i}" {if condition="$v.check eq 1" } checked="" {/if} value="{$v.id}">
        <i class="weui-icon-checked"></i>
      </div>
      <div class="weui-cell__bd">
        <p>{$v.nickname}</p>
      </div>
    </label>
    {/volist}
  </div>


  <a style="margin-top: 50px; background-color:#429ED5;" href="javascript:;" class="group_control weui-btn weui-btn_primary">提交</a>
</body>

{include file="public/footer" /}



<script>
  $(function () {
    $('.group_control').on('click', function () {
   

      $.confirm({
      title: '群监控',
      text: '确认修改群监控吗？',
      onOK: function () {
        var array = [];
        $.each($('input:checkbox'), function () {
          var obj = new Map();
          if (this.checked) {
            obj["id"] = $(this).val();
            obj["nickname"] = $(this).parent('div').next('div').children('p').text();
            array.push(obj);
            // window.alert("你选了："+
            //$('input[type=checkbox]:checked').length+"个，其中有："+$(this).val());
          } else {
            obj["id"] = $(this).val();
            obj["nickname"] = $(this).parent('div').next('div').children('p').text();
            array.indexOf(obj);
          }
        });
        // console.log(array);
        var groups = JSON.stringify(array);
        //  console.log(groups);
        //确认监控的群

        $.post('/index/Index/groupControl', { 'groups': groups, 'uin': '{$user.uin}' }, function (res) {
          if (res.code == 1) {
            $.toast(res.msg, function () {
              window.location.href = "/index/Index/index";
            });
          }
        });
      },
      onCancel: function () {
        $.toast('你取消了',1500)
      }
      });


       




      //console.log(array);
    });
  });

</script>

</html>